package com.dylon.seapiweb.controller;

import com.dylon.common.config.Global;
import com.dylon.system.domain.SysMenu;
import com.dylon.system.domain.SysUsers;
import com.dylon.system.service.ISysMenuService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * 首页 业务处理
 */
@Controller
@Log4j2
public class IndexController extends BaseController {

    @Autowired
    private ISysMenuService sysMenuServiceImpl;

    // 系统首页
    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public String index(ModelMap mmap){
        log.info("跳转首页==========================");
        // 取身份信息
        SysUsers user = getSysUser();
        // 根据用户id取出菜单
        List<SysMenu> menus = sysMenuServiceImpl.selectMenusByUser(user);
        mmap.put("menus", menus);
        mmap.put("user", user);
        mmap.put("copyrightYear", Global.getCopyrightYear());
        return "index";
    }

    // 系统介绍
    @GetMapping("/system/main")
    public String main(ModelMap mmap) {
        mmap.put("version", Global.getVersion());
        return "main";
    }
}




